<template>
    <div>
        <h1>Login</h1>
        <el-form
              ref="ruleFormRef"
              style="max-width: 600px"
              label-width="auto"
              class="demo-ruleForm"
              :size="formSize"
              status-icon>
        <el-form-item label="用户名" prop="login_name">
            <el-input v-model="login_name" />
        </el-form-item>
        <el-form-item label="密码" prop="login_pwd">
            <el-input v-model="login_pwd" />
        </el-form-item>
    </el-form>
        <el-button @click="login">登录</el-button>
    </div>
   
</template>


<script setup>
import { ref } from 'vue'
import { useRouter,useRoute } from 'vue-router'
import { ElNotification } from 'element-plus'
const login_name = ref('')
const login_pwd = ref('')
const token = ref('')
const router = useRouter()
const login = () =>{
    fetch("http://localhost:8282/login/findLogin?login_name="+login_name.value+"&login_pwd="+login_pwd.value,{
        method: 'get',
        mode: 'cors'
    })
    .then(res => res.json())
     .then(res => {
        
        console.log(res)
        if(res.code==2000){
            token.value = res.data;
            localStorage.setItem("token",res.message);
            console.log(res.message)
            router.push('/work')
        }
    })
    .catch(e => console.log(e))
    
    
}

</script>